;;;
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe Street
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;	Copyright: 1997
;;;	   Edited: 12-9-2016
;;;****************************************************************************
(defun c:mhlbl ()
  (if align_lst
    (progn
      (setq mjrg "C"
            prod "VI02"
            llt  "-"
            textlay "C-VI022NOTE"
            staprec 1
      )
      (if stait nil (load"stait"))
      (if gvpno nil (load "gvpno"))
      (gvpno)
      (if dimscl nil (load"dimscl"))
      (dimscl)
      (SETQ	ss_line ""
                thts (ustr 1
    		   "\n\"Leroy Template Size\" or Standard(=110) "
    		   (IF thts
    		     thts
    		     "Standard"
    		   ) ;_ end of IF
    		   nil
    	     ) ;_ end of ustr
      ) ;_ end of SETQ
      (COND	((OR (EQ (SUBSTR thts 1 1) "S") (EQ (SUBSTR thts 1 1) "s"))
    	 (SETQ txcolr "2"
    	       lncolr "1"
    	 ) ;_ end of SETQ
    	)
    	((<= (ATOI thts) 80)
    	 (SETQ txcolr "1"
    	       lncolr "1"
    	 ) ;_ end of SETQ
    	)
    	((<= (ATOI thts) 125)
    	 (SETQ txcolr "2"
    	       lncolr "1"
    	 ) ;_ end of SETQ
    	)
    	((< (ATOI thts) 200)
    	 (SETQ txcolr "3"
    	       lncolr "2"
    	 ) ;_ end of SETQ
    	)
    	((>= (ATOI thts) 200)
    	 (SETQ txcolr "5"
    	       lncolr "2"
    	 ) ;_ end of SETQ
    	)
    	(thts
    	 (SETQ txcolr "2"
    	       lncolr "1"
    	       thts "110"
    	 ) ;_ end of SETQ
    	)
      ) ;_ end of COND
      (IF (OR (EQ (SUBSTR thts 1 1) "S") (EQ (SUBSTR thts 1 1) "s"))
        (SETQ text_ht (* 0.110 dimsc))
        (SETQ text_ht (* (* (ATOI thts) 0.001) dimsc))
      ) ;_ end of IF
      (SETVAR "TEXTSIZE" text_ht)
      (SETQ add_sta 0)          ;(ureal 1 "" "Alignment Beginning Station " (if add_sta add_sta 1000))
      (if (and old_ndx(eq(type old_ndx)'INT))
        (setq lbl_ndx old_ndx)
        (setq lbl_ndx 0)
      )
    (WHILE
      (and
        (setq lbl_ndx (uint 1 "Quit" "Manhole number to label: (or \"Quit\") " (if (< lbl_ndx (length align_lst))(1+ lbl_ndx)lbl_ndx)))
        (/= lbl_ndx "Quit")
        (<= lbl_ndx (length align_lst))
      )
      (SETQ v_twst (GETVAR "viewtwist"))
      (setq lbl_data (nth (1- lbl_ndx) align_lst)
            rim_elev (nth 2 lbl_data)
            cur_sta (+ add_sta(nth 1 lbl_data)))
      (SETQ mh_txt_1  (STRCAT "%%224 MH " (nth 0 lbl_data))
	    mh_txt_2  (STRCAT
			"STA. " (stait cur_sta staprec)
		      ) ;_ end of STRCAT
	    mh_txt_3  (STRCAT "RIM EL=" (RTOS rim_elev 2 1) "'%%222")
	    text_pt1  (nth 9 lbl_data)
	    text_pt2  (POLAR (nth 9 lbl_data)
			     (- 0 (+ v_twst (/ PI 2)))
			     (* text_ht 1.5)
		      ) ;_ end of POLAR
	    text_pt3  (POLAR text_pt2
			     (- 0 (+ v_twst (/ PI 2)))
			     (* text_ht 2.0)
		      ) ;_ end of POLAR
	    text_ptj  (POLAR (POLAR (nth 9 lbl_data)
				    (- 0 (+ v_twst (/ PI 2)))
				    (* text_ht 2)
			     ) ;_ end of POLAR
			     (- 0 (+ v_twst PI))
			     (/ text_ht 2.000)
		      ) ;_ end of POLAR
      ) ;_ end of SETQ
      (SETQ colr "2")
      (c:mklayr)
      (SETQ text_ent1 (LIST (CONS 0 "TEXT")
			    (CONS 1 mh_txt_1)
                            (CONS 8 textlay)
			    (CONS 10 text_pt1)
			    (CONS 40 text_ht)
			    (CONS 50 (- 0 v_twst))
		      ) ;_ end of LIST
      ) ;_ end of SETQ
      (SETQ text_ent2 (LIST (CONS 0 "TEXT")
			    (CONS 1 mh_txt_2)
                            (CONS 8 textlay)
			    (CONS 10 text_pt2)
			    (CONS 40 text_ht)
			    (CONS 50 (- 0 v_twst))
		      ) ;_ end of LIST
      ) ;_ end of SETQ
      (SETQ text_ent3 (LIST (CONS 0 "TEXT")
			    (CONS 1 mh_txt_3)
                            (CONS 8 textlay)
			    (CONS 10 text_pt3)
			    (CONS 40 text_ht)
			    (CONS 50 (- 0 v_twst))
		      ) ;_ end of LIST
      ) ;_ end of SETQ
      (ENTMAKE text_ent1)
      (SETQ text_ss (SSADD (ENTLAST)))
      (ENTMAKE text_ent2)
      (SETQ text_ss (SSADD (ENTLAST) text_ss))
      (ENTMAKE text_ent3)
      (SETQ text_ss (SSADD (ENTLAST) text_ss))
      (SETQ max_tl
        (MAX
          (DISTANCE (CAR(TEXTBOX text_ent1))(CADR(TEXTBOX text_ent1)))
          (DISTANCE (CAR(TEXTBOX text_ent2))(CADR(TEXTBOX text_ent2)))
          (DISTANCE (CAR(TEXTBOX text_ent3))(CADR(TEXTBOX text_ent3)))
        )
      )
      (PRINC "\nPick Note Location. ") ;_ end of PRINC
      (COMMAND "._move"
	       text_ss
	       ""
	       text_ptj
	       pause
	       (SETQ new_text_pt (CADR (GRREAD T 4 1)))
      ) ;_ end of COMMAND
      (SETQ colr "1")
      (c:mklayr)
      (setq new_text_rt (polar new_text_pt (- 0 v_twst)(+ max_tl(* 1.25 text_ht))))
      (if (>(distance new_text_pt (nth 9 lbl_data))(distance new_text_rt (nth 9 lbl_data)))
        (setq tmp_new_pt new_text_pt
              new_text_pt new_text_rt
              new_text_rt tmp_new_pt
              v_twst (+ v_twst PI))
      )
      (SETQ ldr_pt2   (POLAR new_text_pt
			     (- 0 (+ v_twst PI))
			     (* text_ht 2)
		      ) ;_ end of polar
	    ldr_ang   (ANGLE (nth 9 lbl_data) ldr_pt2)
	    ldr_ang_d (* (/ ldr_ang PI) 180.00)
	    ldr_pt    (POLAR (nth 9 lbl_data) ldr_ang (* dimsc 0.0625))
	    fin_bpt   (POLAR new_text_pt
			     (- 0 (+ v_twst (/ PI 2)))
			     (* 2.0 text_ht)
		      ) ;_ end of polar
	    fin_tpt   (POLAR fin_bpt
			     (- 0 (- v_twst (/ PI 2)))
			     (* 4.0 text_ht)
		      ) ;_ end of polar
      ) ;_ end of setq
      (COMMAND "._pline" (nth 9 lbl_data) ldr_pt2 new_text_rt "")       ;(nth 9 lbl_data) was ldr_pt
;      (COMMAND "._line" fin_bpt fin_tpt "")
;      (COMMAND "._insert" "ldraro" ldr_pt dimsc dimsc ldr_ang_d) ;_ end of COMMAND
      (setq old_ndx lbl_ndx)
    )
    (setq lbl_ndx 1)
    )
  )
  (c:rslayr)
  (princ)
)
(defun c:imh ()
  (if align_lst
    (progn
      (if gvpno nil (load "gvpno"))
      (gvpno)
      (if dimscl nil (load"dimscl"))
      (dimscl)
      (if (eq(type lbl_ndx)'INT) nil (setq lbl_ndx 0))
      (WHILE
        (and
          (setq lbl_ndx (uint 1 "Quit" "Manhole number to insert: (or \"Quit\") " (if (< lbl_ndx (length align_lst))(1+ lbl_ndx)lbl_ndx)))
          (/= lbl_ndx "Quit")
          (<= lbl_ndx (length align_lst))
        )
        (SETQ     v_twst (GETVAR "viewtwist"))
        (setq     mh_pt (nth 9(nth (1- lbl_ndx) align_lst)))
        (command ".insert" "SMH" mh_pt dimsc dimsc v_twst)
      )
    )
  )
)